home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / sail.tar / sail / dr_main.c < prev    next >
C/C++ Source or Header  |  1992-10-09  |  2KB  |  88 lines

  1. /*
  2.  * Copyright (c) 1983 Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms are permitted
  6.  * provided that this notice is preserved and that due credit is given
  7.  * to the University of California at Berkeley. The name of the University
  8.  * may not be used to endorse or promote products derived from this
  9.  * software without specific prior written permission. This software
  10.  * is provided ``as is'' without express or implied warranty.
  11.  */
  12.  
  13. #ifndef lint
  14. static char sccsid[] = "@(#)dr_main.c    5.3 (Berkeley) 3/9/88";
  15. #endif /* not lint */
  16.  
  17. #include "driver.h"
  18.  
  19. dr_main()
  20. {
  21.     register int n;
  22.     register struct ship *sp;
  23.     int nat[NNATION];
  24.     int value = 0;
  25.  
  26.     (void) signal(SIGINT, SIG_IGN);
  27.     (void) signal(SIGQUIT, SIG_IGN);
  28.     (void) signal(SIGTSTP, SIG_IGN);
  29.     if (issetuid)
  30.         (void) setuid(geteuid());
  31.     if (game < 0 || game >= NSCENE) {
  32.         fprintf(stderr, "DRIVER: Bad game number %d\n", game);
  33.         exit(1);
  34.     }
  35.     cc = &scene[game];
  36.     ls = SHIP(cc->vessels);
  37.     if (sync_open() < 0) {
  38.         perror("driver: syncfile");
  39.         exit(1);
  40.     }
  41.     for (n = 0; n < NNATION; n++)
  42.         nat[n] = 0;
  43.     foreachship(sp) {
  44.         if (sp->file == NULL &&
  45.             (sp->file = (struct File *)calloc(1, sizeof (struct File))) == NULL) {
  46.             (void) fprintf(stderr, "DRIVER: Out of memory.\n");
  47.             exit(1);
  48.         }
  49.         sp->file->index = sp - SHIP(0);
  50.         sp->file->loadL = L_ROUND;
  51.         sp->file->loadR = L_ROUND;
  52.         sp->file->readyR = R_LOADED|R_INITIAL;
  53.         sp->file->readyL = R_LOADED|R_INITIAL;
  54.         sp->file->stern = nat[sp->nationality]++;
  55.         sp->file->dir = sp->shipdir;
  56.         sp->file->row = sp->shiprow;
  57.         sp->file->col = sp->shipcol;
  58.     }
  59.     windspeed = cc->windspeed;
  60.     winddir = cc->winddir;
  61.     people = 0;
  62.     for (;;) {
  63.         sleep(7);
  64.         if (Sync() < 0) {
  65.             value = 1;
  66.             break;
  67.         }
  68.         if (next() < 0)
  69.             break;
  70.         unfoul();
  71.         checkup();
  72.         prizecheck();
  73.         moveall();
  74.         thinkofgrapples();
  75.         boardcomp();
  76.         compcombat();
  77.         resolve();
  78.         reload();
  79.         checksails();
  80.         if (Sync() < 0) {
  81.             value = 1;
  82.             break;
  83.         }
  84.     }
  85.     sync_close(1);
  86.     return value;
  87. }
  88.